import http from '../request';
const apibase = '/api/JobRecord';

//查询工单
var getPackingPlanList = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetPackingPlanList`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//查询工单
var getPackingPlanListByVerify = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetPackingPlanListByVerify`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//根据工单ID获取批记录
var getJobRecordToList = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (
        apibase +
          `/GetJobRecordToList?PackingPlanID=${data.PackingPlanID}&BatchNo=${data.BatchNo}`
      )
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};

//获取工作记录明细(聚合)
var getJobRecordDetailList = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetJobRecordDetailList?JobRecordID=${data}`)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//获取工作记录明细(聚合)
var getJobRecordDetails = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetJobRecordDetails`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//获取工作记录明细(单例)
var getJobRecordDetailGroupList = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetJobRecordDetailGroupList?JobRecordID=${data}`)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//获取工作记录明细(单例)
var getJobRecordDetailGroups = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetJobRecordDetailGroups`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//提交工作明细
var completedRecordDetai = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/CompletedRecordDetai`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//一键审核
var verifyJobRecord = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/VerifyJobRecord`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//一键弃审
var unVerifyJobRecord = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/UnVerifyJobRecord`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//一键作废
var invaliDateJobRecord = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/InvaliDateJobRecord`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//一键还原
var unInvaliDateJobRecord = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/UnInvaliDateJobRecord`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//查询工作集（审批用）
var getJobRecordToPackingPlanID = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (
        apibase +
          `/GetJobRecordToPackingPlanID?PackingPlanID=${data.PackingPlanID}&BatchNo=${data.BatchNo}`
      )
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//查询工作集（审批用）
var getJobRecordToPacking = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetJobRecordToPacking`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//查询工作集
var getJobRecordList = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetJobRecordList`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//打印
var printJobRecord = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/PrintJobRecord`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
export {
  getPackingPlanList,
  getPackingPlanListByVerify,
  getJobRecordToList,
  getJobRecordDetailList,
  getJobRecordDetailGroupList,
  completedRecordDetai,
  getJobRecordToPackingPlanID,
  getJobRecordToPacking,
  verifyJobRecord,
  unVerifyJobRecord,
  invaliDateJobRecord,
  unInvaliDateJobRecord,
  getJobRecordList,
  getJobRecordDetails,
  getJobRecordDetailGroups,
  printJobRecord,
};
